//- Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. 
//- <https://www.chatopera.com>, Licensed under the Chunsong Public 
//- License, Version 1.0  (the "License"), https://docs.cskefu.com/licenses/v1.html
//- Unless required by applicable law or agreed to in writing, software
//- distributed under the License is distributed on an "AS IS" BASIS,
//- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//- See the License for the specific language governing permissions and
//- limitations under the License.
//- Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>
//- Licensed under the Apache License, Version 2.0
//- http://www.apache.org/licenses/LICENSE-2.0
extends /apps/entim/include/layout.pug

block content
    .ukefu-entim-point.ukefu-entim-msgbox(style='cursor: pointer;', onclick='top.closeentim();')
        i.layui-icon 
        - var newmsg = 0
        if recentUserList
            for recentUser in recentUserList
                - newmsg = recentUser.newmsg + newmsg
        span.layui-anim.layer-anim-05.animated#msgbox(data-newmsg='#{newmsg}', style='#{newmsg == 0?"display:none":""};top: 15px;background-color: red;left: 0px;') #{newmsg}
        |  企业聊天
        .putAway#putAway(title='收起', style='width:30px; height: 100%;float: right')
            i.layui-icon 
    style.
        .putAway:hover {
            background: rgba(0, 0, 0, 0.2);
        }

    script.
        var hostname = location.hostname;
        var socket = io.connect(location.protocol + "//" + top.hostname + ":" + top.port + "/im/ent?userid=#{user.id}");
        socket.on('connect', function () {
        })
        socket.on('message', function (data) {
            $('#msgbox').data("newmsg", $('#msgbox').data("newmsg") + 1).text($('#msgbox').data("newmsg")).show();
        });

        socket.on('disconnect', function () {
        });
        $("#putAway").click(function (e) {
            top.isImIndex = true;
            top.closeentim();
            e.stopPropagation();
        })

